import 'package:get/get.dart';

import '../../network/HttpGo.dart';
import '../../services/user_service.dart';

class MeAuctionLogic extends GetxController {
  List<Map<String, dynamic>> list = [];

  @override
  void onReady() {
    super.onReady();
    getList();
  }

  void getList() async {
    var header = {'token': UserService.to.token};
    final res =
        await HttpGo().post("/auctionGoodHash/myGoodHash", headers: header);
    res.ifSuccess((data) {
      if (data is List) {
        list = data.cast<Map<String, dynamic>>();
        update();
      }
    });
    res.ifFailure((e) => e.toast());
  }

  /// TODO 挂拍上架中。。
  shelves(int id) async {
    var header = {'token': UserService.to.token};
    final res =
        await HttpGo().post('/auctionGoodHash/putGoodHash', data: {
          "id": id,
          "password": "123456"
        },headers: header);
    res.ifSuccess((data) {
      if (data is List) {
        list = data.cast<Map<String, dynamic>>();
        update();
      }
    });
    res.ifFailure((e) => e.toast());
  }
}
